home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1985 Winter
/
rerun-1985-winter.d64
/
wedge utilities
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
2KB
|
65 lines
10 rem sample utility programs
20 rem err-read disk error channel
30 close100:open100,8,15
40 input#100,n,er$,t,s
50 printn;er$;t;s:close100:end
60 rem hex-convert a number from decimal to hexadecimal
70 print"convert to hex"
80 d=0:input"decimal";d:ifd=0thenend
90 h$="":d=d/4096:fori=1to4:t%=d:h$=h$+chr$(48+t%-(t%>9)*7)
100 d=16*(d-t%):next:print"hex "h$:goto80
110 rem dec-convert from hexadecimal to decimal
120 print"convert to decimal"
130 h$="":input"hex";h$:ifh$=""thenend
140 d=0:fori=1to4:t%=asc(h$):t%=t%-48+(t%>64)*7
150 h$=mid$(h$,2):d=16*d+t%:next:print"decimal"d:goto130
160 rem init-initialize disk drive
170 close100:open100,8,15,"i":input#100,n,er$,t,s
180 ifn<>0then50
190 print"drive initialized":end
200 rem scratch-delete a file from disk
210 f$="":input"file";f$:iff$=""thenend
220 print"scratch "f$:input"sure (y/n)";r$:ifr$<>"y"thenend
230 close100:open100,8,15,"s0:"+f$:goto40
240 rem rename-rename a file
250 f1$="":input"old name";f1$:iff1$=""thenend
260 f2$="":input"new name";f2$:iff2$=""thenend
270 close100:open100,8,15,"r0:"+f2$+"="+f1$:goto40
280 rem header-format a new disk
290 f1$="":input"disk name";f1$:iff1$=""orlen(f1$)>16then290
300 f2$="":input"2 char id";f2$:iflen(f2$)<>2then300
310 print"this will erase disk":input"go ahead (y/n)";r$:ifr$<>"y"thenend
320 close100:open100,8,15,"n0:"+f1$+","+f2$:close100:goto20
330 rem dir-print disk directory
340 z$=chr$(0):close100:close101:open100,8,15:open101,8,0,"$0"
350 input#100,n,er$,t,s:ifn<>0then50
360 get#101,a$:ifa$<>""then360
370 printa$;:goto460
380 getc$:ifc$=""then420
390 ifc$<>" "then510
400 getc$:ifc$=""then400
410 ifc$<>" "then510
420 get#101,a$:s=st:a=asc(a$+z$)
430 get#101,b$:s=st:b=asc(b$+z$)
440 ifsthen510
450 ifa=1andb=1thengosub480
460 get#101,a$:ifa$=""thenprint:goto380
470 printa$;:goto460
480 get#101,a$:s=st:a=asc(a$+z$)
490 get#101,b$:s=st:b=asc(b$+z$)
500 n=b*256+a:printn;:return
510 close101:close100
520 end
530 rem help-print documentation
540 print:print"commands available are:"
550 print"err -read error channel"
560 print"hex -convert number to hex"
570 print"dec -convert number to decimal"
580 print"init -initialize disk drive"
590 print"scratch -delete disk file"
600 print"rename -rename a disk file"
610 print"header -format a new disk"
620 print"dir -print the disk directory"
630 print"help -print this help message"
640 end